package office.service.workflow.impl;

import java.util.List;

import office.bo.workflow.impl.Transfer;
import office.domainset.BizDomainProviderSetImpl;
import office.service.workflow.IWorkFlowService;
import platform.common.dao.impl.DaoConfigException;
import platform.common.dao.impl.DaoException;
import platform.common.service.impl.BaseBizServiceImpl;

public class WorkFlowService extends BaseBizServiceImpl implements IWorkFlowService {

	@SuppressWarnings("unchecked")
	@Override
	public String getCodeByRoleName(String roleName) {
		BizDomainProviderSetImpl domainProviderSetImpl = (BizDomainProviderSetImpl) domainProviderSet;
		String params[] ={roleName}; 
		try {
			List<Transfer> list = domainProviderSetImpl.getDao().findByHqlNameAndDomian(domainProviderSetImpl.getTransferDP(), "codeByRoleName", params);
			if(list != null && list.size() > 0){
				Transfer transfer = list.get(0);
				return transfer.getCode();
			}
			return null;
		} catch (DaoException e) {
			log.error("", e);
		} catch (DaoConfigException e) {
			log.error("", e);
		}
		return null;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Transfer> getRoleNameByCode(String code) {
		BizDomainProviderSetImpl domainProviderSetImpl = (BizDomainProviderSetImpl) domainProviderSet;
		String params[] ={code}; 
		try {
			List<Transfer> list = domainProviderSetImpl.getDao().findByHqlNameAndDomian(domainProviderSetImpl.getTransferDP(), "roleNameByCode", params);
			return list;
		} catch (DaoException e) {
			log.error("", e);
		} catch (DaoConfigException e) {
			log.error("", e);
		}
		return null;
	}
	
}
